<!DOCTYPE html>
<html lang="en">

<head>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<meta charset="utf-8">
	<title></title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
	<meta name="description" content="">
	<meta name="author" content="">
	<link rel="stylesheet" type="text/css" href="../../css/cloud-admin.css" />
	<link rel="stylesheet" type="text/css" href="../../css/themes/default.css" id="skin-switcher" />
	<link rel="stylesheet" type="text/css" href="../../css/responsive.css" />
	<link href="../../font-awesome/css/font-awesome.min.css" rel="stylesheet">
	<!-- SELECT2 -->
	<link rel="stylesheet" type="text/css" href="../../js/select2/select2.min.css" />
	<!-- UNIFORM -->
	<link rel="stylesheet" type="text/css" href="../../js/uniform/css/uniform.default.min.css" />
	<!-- datatable -->
	<link rel="stylesheet" href="../../js/datatables/datatable.css">
	<link rel="stylesheet" href="../../js/datepicker/datepicker.css">
	<!-- file-input -->
	<link rel="stylesheet" type="text/css" href="../../js/file-input/fileinput.css" />
	<!-- zt -->
	<link rel="stylesheet" type="text/css" href="../../css/zt/editor.css">
	<script src="../../js/jquery/jquery-2.0.3.min.js"></script>
	<script src="../../js/common.js"></script>
</head>

<body>
	<header class="navbar clearfix" id="header"></header>
	<!-- PAGE -->
	<section id="page">
		<!-- 侧边栏 -->
		<div id="sidebar" class="sidebar">
			<div class="sidebar-menu nav-collapse">

				<!-- SIDEBAR MENU -->
				<ul>
				</ul>
			</div>


		</div>
		<!-- /侧边栏 -->
		<div id="main-content">
			<!-- /SAMPLE BOX CONFIGURATION MODAL FORM-->
			<div class="modal fade" id="box-qrcode" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-dialog" style="width:250px">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							<h4 class="modal-title">预览</h4>
						</div>
						<div class="modal-body">
							<p>
								<a href="" target="_blank">点击查看</a>
							</p>
							<img width="200" height="200" />
						</div>

					</div>
				</div>
			</div>
			<div class="modal fade bs-example-modal-lg" id="productpack_detail" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog modal-lg" style="width:900px;">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
								<h4 class="modal-title">选择商品</h4>
							</div>
							<div class="modal-body">
								<div class="row" style="height:auto">
									<label class="control-label col-md-2" style="line-height:30px;">产品名称：</label>
									<div class="col-md-8 inline">
										<input type="text" class="form-control width-50" name="q" placeholder="请输入产品名称" style="height:33px;"/>
										<a class="btn btn-primary search-product" style="margin-left: 10px;">查询</a>
										<a class="btn btn-danger delect-product" style="margin-left: 10px;">全部取消</a>
										<span class="select-product-id" style="color:red;display: inline-block; line-height: 30px;"></span>
									</div>
		
								</div>
								<div class="form-group" style="height:auto">
									<table id="productpack_product" cellpadding="0" cellspacing="0" border="0"
										   class="datatable table table-striped table-bordered table-hover">
									</table>
								</div>
							</div>
							<div class="modal-footer">
								<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
							</div>
						</div>
					</div>
				</div>
			<div class="container">
				<div class="row">
					<!-- CONTENT -->
					<div id="content" class="col-lg-12">
						<!-- PAGE HEADER-->
						<div class="row">
							<div class="col-sm-12">
								<div class="page-header">
									<!-- BREADCRUMBS -->
									<ul class="breadcrumb">
										<li>
											<i class="fa fa-home"></i>
											<a href="index.html">首页</a>
										</li>
										<li>
											<a href="#">页面模板</a>
										</li>
										<li>新建模板</li>
									</ul>
									<!-- /BREADCRUMBS -->
								</div>
							</div>
						</div>
						<!-- /PAGE HEADER -->
						<!-- SAMPLE -->
						<!--template-->
						<div class="ztMainUI">

							<div class="UIdesign clearfix">
								<div class="UIpreview">
									<div class="UIpreview-headder">专题页面</div>
									<div class="app-entry">
										<div class="app-field tips">
											<div class="goods-template-block">
												<p>点击上方标题编辑页面信息</p>
												<p>点击下方按钮增加页面区域</p>
											</div>
										</div>


									</div>
									<div class="js-add-region">
										<h4>添加内容</h4>
										<ul>
											<li>
												<a href="javascript:;" class="add_banner" data-target="bannerHtml">通栏图</a>
											</li>
											<li>
												<a href="javascript:;" class="add_product" data-target="productHtml">商品列表</a>
											</li>
											<li>
												<a href="javascript:;" class="add_coupon" data-target="couponHtml">领券</a>
											</li>
											<li>
												<a href="javascript:;" class="add_category" data-target="categoryHtml">分类</a>
											</li>
											<li>
												<a href="javascript:;" class="add_swiper" data-target="swiperHtml">首页轮播</a>
											</li>
											<li>
												<a href="javascript:;" class="add_pairs" data-target="pairsHtml">套装</a>
											</li>
										</ul>
									</div>
								</div>
								<div class="UIsidebar">
									<div class="arrow"></div>




								</div>
							</div>
						</div>
						<!--/template-->
					</div>
				</div>
			</div>
		</div>
		<!-- /CONTENT-->
		<div class="row clearfix" style="height: 30px;">
			<div style="text-align: center;">
				<div class="box">
					<a href="javascript:;" class="btn btn-success config bt-submit" style="width: 100px;margin-top:20px;">保存</a>
					<a href="javascript:;" class="btn btn-danger config bt-review" style="width: 100px;margin-left:20px; margin-top:20px;">预览</a>
					<a href="javascript:history.go(-1);" class="btn btn-default" style="width: 100px;margin-left:20px; margin-top:20px;">取消并返回</a>
				</div>
			</div>
		</div>
		<!-- /SAMPLE -->

		<div id="bannerHtml" style="display:none">
			<div class="app-field divId" data-type="banner">
				<div class="group">
					<ul class="group-col-1">
						<li>
							<a href="javascript:;">
								<img style="" src="../../img/nessn269.jpg">
							</a>
						</li>
					</ul>
				</div>

				<div class="actions">
					<div class="actions-wrap">
						<span class="action edit">编辑</span>
						<span class="action add">加内容</span>
						<span class="action delete">删除</span>
					</div>
				</div>
			</div>
		</div>
		<div id="pairsHtml" style="display:none">
			<div class="app-field divId" data-type="pairs">
				<div class="group">
					<ul class="group-col-1">
						<li>
							<a href="javascript:;">
								<img style="" src="../../img/nessn269.jpg">
							</a>
						</li>
					</ul>
				</div>

				<div class="actions">
					<div class="actions-wrap">
						<span class="action edit">编辑</span>
						<span class="action add">加内容</span>
						<span class="action delete">删除</span>
					</div>
				</div>
			</div>
		</div>
		</div>
		<div id="couponHtml" style="display:none">
			<div class="app-field divId " data-type="coupon">
				<div class="group">
					<ul class="group-col-1">
						<li>
							<a href="javascript:;">
								<img style="" src="../../img/nessn269.jpg">
							</a>
						</li>
					</ul>
				</div>

				<div class="actions">
					<div class="actions-wrap">
						<span class="action edit">编辑</span>
						<span class="action add">加内容</span>
						<span class="action delete">删除</span>
					</div>
				</div>

			</div>
		</div>
		<div id="productHtml" style="display:none">
			<div class="app-field divId" data-type="product">
				<div class="group">
					<ul class="group-col-2">
						<li>
							<a href="javascript:;">
								<img src="http://img1.yiigoo.com/images/200.jpg">
							</a>
						</li>
						<li>
							<a href="javascript:;">
								<img src="http://img1.yiigoo.com/images/200.jpg">
							</a>
						</li>
					</ul>
				</div>
				<div class="actions">
					<div class="actions-wrap">
						<span class="action edit">编辑</span>
						<span class="action add">加内容</span>
						<span class="action delete">删除</span>
					</div>
				</div>
			</div>
		</div>
		<div id="swiperHtml" style="display:none">
			<div class="app-field divId" data-type="swiper">
				<div class="group">
					<ul class="group-col-2">
						<li>
							<a href="javascript:;">
								<img src="http://img1.yiigoo.com/images/200.jpg">
							</a>
						</li>
						<li>
							<a href="javascript:;">
								<img src="http://img1.yiigoo.com/images/200.jpg">
							</a>
						</li>
					</ul>
				</div>
				<div class="actions">
					<div class="actions-wrap">
						<span class="action edit">编辑</span>
						<span class="action add">加内容</span>
						<span class="action delete">删除</span>
					</div>
				</div>
			</div>
		</div>
		<!-- 分类 -->
		<div id="categoryHtml" style="display:none">
			<div class="app-field divId" data-type="category">
				<div class="group">
					<ul class="group-col-4">
						<li>
							<a href="javascript:;">
								<img src="http://img1.yiigoo.com/images/200.jpg">
							</a>
						</li>
						<li>
							<a href="javascript:;">
								<img src="http://img1.yiigoo.com/images/200.jpg">
							</a>
						</li>
						<li>
							<a href="javascript:;">
								<img src="http://img1.yiigoo.com/images/200.jpg">
							</a>
						</li>
						<li>
							<a href="javascript:;">
								<img src="http://img1.yiigoo.com/images/200.jpg">
							</a>
						</li>
					</ul>
				</div>
				<div class="actions">
					<div class="actions-wrap">
						<span class="action edit">编辑</span>
						<span class="action add">加内容</span>
						<span class="action delete">删除</span>
					</div>
				</div>
			</div>
		</div>

		<div id="editBanner" style="display:none">
			<div class="clearfix">
				<div class="app-sidebar-inner">
					<div>
						<div class="form-horizontal" novalidate="">
							<div class="control-group">
								<div class="control-group">
									<label class="control-label">
										</em>显示列数：</label>
									<div class="controls">
										<input class="input-xxlarge" type="hidden" name="rows" value=1 onkeypress="return $.IsNum(event);" onblur="return $.IsNaN(this);"
										 maxlength="1" style="width:100px;">
										<label class="radio inline">
											<input name="product_radio" checked="checked" value="1" type="radio">1列
										</label>
										<label class="radio inline">
											<input name="product_radio" value="2" type="radio">2列
										</label>
										<label class="radio inline">
											<input name="product_radio" value="3" type="radio">3列
										</label>
									</div>
								</div>
								<div class="control-group mt10">
									<label class="control-label">上传图片：</label>
									<form name="formDiv">
										<div class="controls col-lst2">
											<div class="lst-addimg">
												<p class="addimg aImg">+
													<input class="upImg" data-index=0 name="uploadFile" type="file" upload-file="uploadImg" />
												</p>
												<p class="addimg newImg" style="display:none">
													<a href="javascript:;">
														<span class="action">删除</span>
														<img>
													</a>
												</p>
												<input class="input-xxlarge" name="productId" placeholder="请输入图片链接" type="text">
											</div>
										</div>
									</form>
								</div>
								<!--  <div class="control-group">
													        <label class="control-label">图片链接：</label>
													        <div class="controls">
													            <input class="input-xxlarge" name="productId" placeholder="请输入图片链接" type="text">
													        </div>
													    </div> -->
								<div class="control-group divimgsize">
									<label class="control-label"></label>
									<p class="red">图片宽度为
										<span class="imgsize"></span>px,高度不限</p>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div id="editPairs" style="display:none">
			<div class="clearfix">
				<div class="app-sidebar-inner">
					<div>
						<div class="form-horizontal" novalidate="">
							<div class="control-group">
								<div class="control-group mt10">
									<label class="control-label">上传图片：</label>
									<form name="formDiv">
										<div class="controls col-lst2">
											<div class="lst-addimg">
												<p class="addimg aImg">+
													<input class="upImg" data-index=0 name="uploadFile" type="file" upload-file="uploadImg" />
												</p>
												<p class="addimg newImg" style="display:none">
													<a href="javascript:;">
														<span class="action">删除</span>
														<img>
													</a>
												</p>
											</div>
										</div>
									</form>
								</div>
								<div class="control-group divimgsize">
									<label class="control-label"></label>
									<p class="red">图片宽度为
										<span class="imgsize"></span>px,高度不限</p>
								</div>
								<div style="padding: 10px 6px 0">
									<label class="control-label"></label>
									<input type="text" placeholder="请输入套装商品id" class='pairsInput'/>
									<!-- <button class="btn btn-primary select-product">选择商品</button>
									<span class='select-product-id' style="color:red"></span> -->
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!--礼券种类-->
		<div id="editCoupon" style="display:none">
			<div class="clearfix">
				<div class="app-sidebar-inner">
					<div>
						<div class="form-horizontal" novalidate="">
							<div class="control-group">
								<label class="control-label">
									</em>礼券种类：</label>
								<div class="controls">
									<label class="radio inline">
										<input name="template_style" value="1" checked="checked" type="radio">1种券（礼包）
									</label>
									<label class="radio inline">
										<input name="template_style" value="2" type="radio">2种券
									</label>
									<label class="radio inline">
										<input name="template_style" value="3" type="radio">3种券
									</label>
									<label class="radio inline">
										<input name="template_style" value="4" type="radio">4种券
									</label>
									<label class="radio inline">
										<input name="template_style" value="5" type="radio">抽奖礼包
									</label>
									<label class="radio inline">
										<input name="template_style" value="6" type="radio">试用抽奖
									</label>
								</div>
							</div>

							<div class="control-group mt10 radio1">
								<label class="control-label">上传图片：</label>
								<form name="formDiv">
									<div class="controls col-lst2">
										<div class="lst-addimg">
											<p class="addimg aImg">+
												<input class="upImg" data-index=0 name="uploadFile" type="file" upload-file="uploadImg" />
											</p>
											<p class="addimg newImg" style="display:none">
												<a href="javascript:;">
													<span class="action">删除</span>
													<img>
												</a>
											</p>
											<input type="text" name="productId" placeholder="批次ID" style="width:150px">
										</div>

									</div>

								</form>
							</div>
							<div class="control-group mt10 radio2" style="display:none">
								<label class="control-label">上传图片：</label>
								<form name="formDiv">
									<div class="controls col-lst2">
										<div class="lst-addimg">
											<p class="addimg aImg">+
												<input class="upImg" data-index=0 name="uploadFile" type="file" upload-file="uploadImg" />
											</p>
											<p class="addimg newImg" style="display:none">
												<a href="javascript:;">
													<span class="action">删除</span>
													<img>
												</a>
											</p>
											<input type="text" name="productId" placeholder="批次ID">
										</div>
										<div class="lst-addimg">
											<p class="addimg aImg">+
												<input class="upImg" data-index=1 name="uploadFile" type="file" upload-file="uploadImg" />
											</p>
											<p class="addimg newImg" style="display:none">
												<a href="javascript:;">
													<span class="action">删除</span>
													<img>
												</a>
											</p>
											<input type="text" name="productId" placeholder="批次ID">
										</div>
									</div>

								</form>
							</div>
							<div class="control-group mt10 radio3" style="display:none">
								<label class="control-label">上传图片：</label>
								<form name="formDiv">
									<div class="controls col-lst3">
										<div class="lst-addimg">
											<p class="addimg aImg">+
												<input class="upImg" data-index=0 name="uploadFile" type="file" upload-file="uploadImg" />
											</p>
											<p class="addimg newImg" style="display:none">
												<a href="javascript:;">
													<span class="action">删除</span>
													<img>
												</a>
											</p>
											<input type="text" name="productId" placeholder="批次ID">
										</div>
										<div class="lst-addimg">
											<p class="addimg aImg">+
												<input class="upImg" data-index=1 name="uploadFile" type="file" upload-file="uploadImg" />
											</p>
											<p class="addimg newImg" style="display:none">
												<a href="javascript:;">
													<span class="action">删除</span>
													<img>
												</a>
											</p>
											<input type="text" name="productId" placeholder="批次ID">
										</div>
										<div class="lst-addimg">
											<p class="addimg aImg">+
												<input class="upImg" data-index=1 name="uploadFile" type="file" upload-file="uploadImg" />
											</p>
											<p class="addimg newImg" style="display:none">
												<a href="javascript:;">
													<span class="action">删除</span>
													<img>
												</a>
											</p>
											<input type="text" name="productId" placeholder="批次ID">
										</div>

									</div>

								</form>
							</div>
							<div class="control-group mt10 radio4" style="display:none">
								<label class="control-label">上传图片：</label>
								<form name="formDiv">
									<div class="controls col-lst4">
										<div class="lst-addimg">
											<p class="addimg aImg">+
												<input class="upImg" data-index=0 name="uploadFile" type="file" upload-file="uploadImg" />
											</p>
											<p class="addimg newImg" style="display:none">
												<a href="javascript:;">
													<span class="action">删除</span>
													<img>
												</a>
											</p>
											<input type="text" name="productId" placeholder="批次ID">
										</div>
										<div class="lst-addimg">
											<p class="addimg aImg">+
												<input class="upImg" data-index=1 name="uploadFile" type="file" upload-file="uploadImg" />
											</p>
											<p class="addimg newImg" style="display:none">
												<a href="javascript:;">
													<span class="action">删除</span>
													<img>
												</a>
											</p>
											<input type="text" name="productId" placeholder="批次ID">
										</div>
										<div class="lst-addimg">
											<p class="addimg aImg">+
												<input class="upImg" data-index=1 name="uploadFile" type="file" upload-file="uploadImg" />
											</p>
											<p class="addimg newImg" style="display:none">
												<a href="javascript:;">
													<span class="action">删除</span>
													<img>
												</a>
											</p>
											<input type="text" name="productId" placeholder="批次ID">
										</div>
										<div class="lst-addimg">
											<p class="addimg aImg">+
												<input class="upImg" data-index=1 name="uploadFile" type="file" upload-file="uploadImg" />
											</p>
											<p class="addimg newImg" style="display:none">
												<a href="javascript:;">
													<span class="action">删除</span>
													<img>
												</a>
											</p>
											<input type="text" name="productId" placeholder="批次ID">
										</div>
									</div>

								</form>
							</div>

							<div class="control-group mt10">
								<label class="control-label"></label>
								<p class="red"> 1、多个批次ID用逗号分隔。</p>
							</div>
							<div class="control-group">
								<label class="control-label"></label>
								<p class="red"> 2、发两张请写两遍批次ID，如11,12,13,14,11,12,13。</p>
							</div>
							<div class="control-group divimgsize">
								<label class="control-label"></label>
								<p class="red">图片宽度为
									<span class="imgsize"></span>px,高度不限</p>
							</div>




						</div>
					</div>
				</div>
			</div>
			<!--END 礼券种类-->

			<!--商品种类编辑-->
			<div id="editProduct" style="display:none">
				<div class="clearfix">
					<div class="app-sidebar-inner">
						<div>
							<div class="form-horizontal" novalidate="">
								<div class="control-group">
									<label class="control-label">
										</em>显示列数：</label>
									<div class="controls">

										<label class="radio inline">
											<input name="product_radio" checked="checked" value="2" type="radio">2列
										</label>
										<label class="radio inline">
											<input name="product_radio" value="3" type="radio">3列
										</label>
										<label class="radio inline">
											<input name="product_radio" value="4" type="radio">4列
										</label>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">显示行数：</label>
									<div class="controls">
										<input class="input-xxlarge" placeholder="请输入行数" type="text" name="rows" value=1 onkeypress="return $.IsNum(event);" onblur="return $.IsNaN(this);"
										 maxlength="1" style="width:100px;">
									</div>
								</div>
								<div class="control-group mt10">
									<label class="control-label">上传图片：</label>
									<form name="formDiv">
										<div class="controls col-lst2">
											<div class="lst-addimg">
												<p class="addimg aImg">+
													<input class="upImg" data-index=0 name="uploadFile" type="file" upload-file="uploadImg" />
												</p>
												<p class="addimg newImg" style="display:none">
													<a href="javascript:;">
														<span class="action">删除</span>
														<img>
													</a>
												</p>
												<input type="text" name="productId" placeholder="产品ID">
											</div>
											<div class="lst-addimg">
												<p class="addimg aImg">+
													<input class="upImg" data-index=1 name="uploadFile" type="file" upload-file="uploadImg" />
												</p>
												<p class="addimg newImg" style="display:none">
													<a href="javascript:;">
														<span class="action">删除</span>
														<img>
													</a>
												</p>
												<input type="text" name="productId" placeholder="产品ID">
											</div>
										</div>

									</form>
								</div>
								<div class="control-group divimgsize">
									<label class="control-label"></label>
									<p class="red">图片宽度为
										<span class="imgsize"></span>px,高度不限</p>
								</div>
							</div>
						</div>
					</div>
				</div>

				<!--/END 商品种类编辑-->
				<!--首页轮播编辑-->
				<div id="editSwiper" style="display:none">
					<div class="clearfix">
						<div class="app-sidebar-inner">
							<div>
								<div class="form-horizontal" novalidate="">
									<div class="control-group">
										<label class="control-label">
											</em>显示列数：</label>
										<div class="controls">
											<label class="radio inline">
												<input name="product_radio" checked="checked" value="1" type="radio">1列
											</label>
											<label class="radio inline">
												<input name="product_radio" checked="checked" value="2" type="radio">2列
											</label>
											<label class="radio inline">
												<input name="product_radio" value="3" type="radio">3列
											</label>
											<label class="radio inline">
												<input name="product_radio" value="4" type="radio">4列
											</label>
										</div>
									</div>
									<div class="control-group">
										<label class="control-label">显示行数：</label>
										<div class="controls">
											<input class="input-xxlarge" placeholder="请输入行数" type="text" name="rows" value=1 onkeypress="return $.IsNum(event);" onblur="return $.IsNaN(this);"
											 maxlength="1" style="width:100px;">
										</div>
									</div>
									<div class="control-group mt10">
										<label class="control-label">上传图片：</label>
										<form name="formDiv">
											<div class="controls col-lst2">
												<div class="lst-addimg">
													<p class="addimg aImg">+
														<input class="upImg" data-index=0 name="uploadFile" type="file" upload-file="uploadImg" />
													</p>
													<p class="addimg newImg" style="display:none">
														<a href="javascript:;">
															<span class="action">删除</span>
															<img>
														</a>
													</p>
													<input type="text" name="productId" placeholder="产品ID">
												</div>
												<div class="lst-addimg">
													<p class="addimg aImg">+
														<input class="upImg" data-index=1 name="uploadFile" type="file" upload-file="uploadImg" />
													</p>
													<p class="addimg newImg" style="display:none">
														<a href="javascript:;">
															<span class="action">删除</span>
															<img>
														</a>
													</p>
													<input type="text" name="productId" placeholder="产品ID">
												</div>
											</div>

										</form>
									</div>
									<div class="control-group divimgsize">
										<label class="control-label"></label>
										<p class="red">图片宽度为
											<span class="imgsize"></span>px,高度不限</p>
									</div>
								</div>
							</div>
						</div>
					</div>

					<!--/END 商品种类编辑-->
					<!--添加内容-->
					<div id="addContent" style="display:none">
						<div class="clearfix">
							<div class="app-sidebar-inner">
								<div>
									<div class="form-horizontal" novalidate="">
										<div class="control-group">
											<label class="control-label">
												<em class="required">*</em>添加内容：</label>
											<div class="controls">
												<ul>
													<li>
														<a href="javascript:;" class="add_banner" data-target="bannerHtml">通栏图</a>
													</li>
													<li>
														<a href="javascript:;" class="add_product" data-target="productHtml">商品列表</a>
													</li>
													<li>
														<a href="javascript:;" class="add_coupon" data-target="couponHtml">领券</a>
													</li>
													<li>
														<a href="javascript:;" class="add_category" data-target="categoryHtml">分类</a>
													</li>
													<li>
														<a href="javascript:;" class="add_swiper" data-target="swiperHtml">首页轮播</a>
													</li>
													<li>
														<a href="javascript:;" class="add_pairs" data-target="pairsHtml">套装</a>
													</li>
												</ul>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<!--END 添加内容-->
					<!--分类编辑-->
					<div id="editCategory" style="display:none">
						<div class="clearfix">
							<div class="app-sidebar-inner">
								<div>
									<div class="form-horizontal" novalidate="">
										<div class="control-group">
											<label class="control-label">
												</em>显示列数：</label>
											<div class="controls">
												<label class="radio inline">
													<input name="product_radio" value="4" type="radio">4列
												</label>
												<label class="radio inline">
													<input name="product_radio" value="5" type="radio">5列
												</label>
											</div>
										</div>
										<div class="control-group">
											<label class="control-label">显示行数：</label>
											<div class="controls">
												<input class="input-xxlarge" placeholder="请输入行数" type="text" name="rows" value=1 onkeypress="return $.IsNum(event);" onblur="return $.IsNaN(this);"
												 maxlength="1" style="width:100px;">
											</div>
										</div>
										<div class="control-group mt10">
											<label class="control-label">上传图片：</label>
											<form name="formDiv">
												<div class="controls col-lst4">
													<div class="lst-addimg" style="width:150px">
														<p class="addimg aImg" style="margin-left:40px">+
															<input class="upImg" data-index=0 name="uploadFile" type="file" upload-file="uploadImg" />
														</p>
														<p class="addimg newImg" style="display:none;margin-left:40px">
															<a href="javascript:;">
																<span class="action">删除</span>
																<img>
															</a>
														</p>
														<input type="text" name="productId" style="width:150px" placeholder="链接">
													</div>
													<div class="lst-addimg" style="width:150px">
														<p class="addimg aImg" style="margin-left:40px">+
															<input class="upImg" data-index=1 name="uploadFile" type="file" upload-file="uploadImg" />
														</p>
														<p class="addimg newImg" style="display:none;margin-left:40px">
															<a href="javascript:;">
																<span class="action">删除</span>
																<img>
															</a>
														</p>
														<input type="text" name="productId" style="width:150px" placeholder="链接">
													</div>
													<div class="lst-addimg" style="width:150px">
														<p class="addimg aImg" style="margin-left:40px">+
															<input class="upImg" data-index=0 name="uploadFile" type="file" upload-file="uploadImg" />
														</p>
														<p class="addimg newImg" style="display:none;margin-left:40px">
															<a href="javascript:;">
																<span class="action">删除</span>
																<img>
															</a>
														</p>
														<input type="text" name="productId" style="width:150px" placeholder="链接">
													</div>
													<div class="lst-addimg" style="width:150px">
														<p class="addimg aImg" style="margin-left:40px">+
															<input class="upImg" data-index=0 name="uploadFile" type="file" upload-file="uploadImg" />
														</p>
														<p class="addimg newImg" style="display:none;margin-left:40px">
															<a href="javascript:;">
																<span class="action">删除</span>
																<img>
															</a>
														</p>
														<input type="text" name="productId" style="width:150px" placeholder="链接">
													</div>
													<div class="lst-addimg" style="width:150px;display:none">
														<p class="addimg aImg" style="margin-left:40px">+
															<input class="upImg" data-index=0 name="uploadFile" type="file" upload-file="uploadImg" />
														</p>
														<p class="addimg newImg" style="display:none;margin-left:40px">
															<a href="javascript:;">
																<span class="action">删除</span>
																<img>
															</a>
														</p>
														<input type="text" name="productId" style="width:150px" placeholder="链接">
													</div>
												</div>

											</form>
										</div>
										<div class="control-group divimgsize">
											<label class="control-label"></label>
											<p class="red">图片宽度为
												<span class="imgsize"></span>px,高度不限</p>
										</div>
									</div>
								</div>
							</div>
						</div>

						<!--/END 商品种类编辑-->

						<!-- 上传hml -->
						<div id="uploadHtml" style="display:none">
							<div class="lst-addimg">
								<p class="addimg aImg">+
									<input class="upImg" name="uploadFile" type="file" upload-file="uploadImg" />
								</p>
								<p class="addimg newImg" style="display:none">
									<a href="javascript:;">
										<span class="action">删除</span>
										<img>
									</a>
								</p>
								<input type="text" name="productId" placeholder="产品ID">
							</div>
						</div>
						<!-- end 上传html -->
						<!-- 上传分类hml -->
						<div id="uploadCategoryHtml" style="display:none">
							<div class="lst-addimg" style="width: 150px">
								<p class="addimg aImg" style="margin-left:40px">+
									<input class="upImg" name="uploadFile" type="file" upload-file="uploadImg" />
								</p>
								<p class="addimg newImg" style="display:none;margin-left:40px">
									<a href="javascript:;">
										<span class="action">删除</span>
										<img>
									</a>
								</p>
								<input type="text" name="productId" style="width: 150px" placeholder="链接">
							</div>
						</div>
						<!-- end 上传分类html -->

						<!-- 模板名称 -->
						<div id="basicHtml" style="display:none">

							<div class="clearfix">
								<div class="app-sidebar-inner">
									<div>
										<div class="form-horizontal" novalidate="">
											<div class="control-group" style="line-height: 20px;margin-bottom:5px">
												<label class="control-label">
													<em class="required">*</em>模版名称：</label>
												<div class="controls">
													<input class="input-xxlarge" name="pageTitle" value="" type="text">
												</div>
											</div>
											<div class="control-group" style="line-height: 20px;margin-bottom:5px">
												<label class="control-label">
													<em class="required">*</em>页面类型：</label>
												<div class="controls">
													<select id="status_select" class="col-md-6 select2-offscreen" tabindex="-1">
														<option value="-1" pageUrl="">请选择页面类型</option>
														<option value="Mall" pageUrl="mall/index.html">首页</option>

														<option value="Category" pageUrl="static/category.html">分类页</option>
														<option value="RedPacket" pageUrl="static/quan.html">红包页</option>
														<option value="BigPacket" pageUrl="static/biggift.html">大礼包</option>
														<option value="Promotion" pageUrl="static/">专题带菜单</option>
														<option value="PromotionNoMenu" pageUrl="static/">专题不带菜单</option>
														<option value="TryProduct" pageUrl="static/">试用抽奖</option>
														<option value="Advertising" pageUrl="static/">小程序广告</option>

													</select>
												</div>
											</div>
											<div class="control-group" style="line-height: 20px;margin-bottom:5px">
												<label class="control-label">
													<em class="required">*</em>页面链接：</label>
												<div class="controls">
													<input class="input-xxlarge" name="pageLink" readonly="readonly" type="text">
												</div>
											</div>
											<div class="control-group" style="line-height: 20px;margin-bottom:5px">
												<label class="control-label">
													<em class="required">*</em>分享标题：</label>
												<div class="controls">
													<input class="input-xxlarge" name="shareTitle" maxlength="50" type="text">
												</div>
											</div>
											<div class="control-group" style="line-height: 20px;margin-bottom:5px">
												<label class="control-label">
													<em class="required">*</em>分享内容：</label>
												<div class="controls">
													<input class="input-xxlarge" name="shareContent" maxlength="50" type="text">
												</div>
											</div>
											<div class="control-group" style="line-height: 20px;margin-bottom:5px">
												<label class="control-label">
													<em class="required">*</em>回跳链接：</label>
												<div class="controls">
													<input class="input-xxlarge" name="shareLink" maxlength="200" type="text">
												</div>
											</div>
											<div class="control-group">
												<label class="control-label">
													<em class="required">*</em>分享图片：</label>
												<form name="formDiv">
													<div class="controls col-lst2">
														<div class="lst-addimg">
															<p class="addimg aImg">+
																<input class="upImg" data-index=0 name="uploadFile" type="file" upload-file="uploadImg" />
															</p>
															<p class="addimg newImg" style="display:none">
																<a href="javascript:;">
																	<span class="action">删除</span>
																	<img>
																</a>
															</p>

														</div>
													</div>
												</form>
											</div>
										</div>
									</div>
								</div>


							</div>

	</section>
	<!--/PAGE -->
	<!-- JAVASCRIPTS -->

	<!-- JQUERY UI-->
	<script src="../../js/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.min.js"></script>
	<!-- BOOTSTRAP -->
	<script src="../../bootstrap-dist/js/bootstrap.min.js"></script>
	<!-- SLIMSCROLL -->
	<script type="text/javascript" src="../../js/jQuery-slimScroll-1.3.0/jquery.slimscroll.min.js"></script>
	<script type="text/javascript" src="../../js/jQuery-slimScroll-1.3.0/slimScrollHorizontal.min.js"></script>
	<!-- BLOCK UI -->
	<script type="text/javascript" src="../../js/jQuery-BlockUI/jquery.blockUI.min.js"></script>
	<!--bootbox-->
	<script type="text/javascript" src="../../js/bootbox/bootbox.min.js"></script>
	<!-- AUTOSIZE -->
	<script type="text/javascript" src="../../js/autosize/jquery.autosize.min.js"></script>
	<!-- spinner -->
	<script src="../../js/spinner/spin.js"></script>
	<!-- bootstrap-fileupload -->
	<script type="text/javascript" src="../../js/bootstrap-fileupload/jquery.iframe-transport.js"></script>
	<script type="text/javascript" src="../../js/bootstrap-fileupload/jquery.fileupload.min.js"></script>

	<!-- INPUT MASK -->
	<script type="text/javascript" src="../../js/bootstrap-inputmask/bootstrap-inputmask.min.js"></script>
	<script type="text/javascript" src="../../js/datatables/bootstrap-select.js"></script>
	<script type="text/javascript" src="../../js/datatables/datatable.js"></script>
	<script type="text/javascript" src="../../js/datatables/datatable-bootstrap.js"></script>
	<script type="text/javascript" src="../../js/datatables/datatable-tabletools.js"></script>

	<!-- SELECT2 -->
	<script type="text/javascript" src="../../js/select2/select2.min.js"></script>
	<!-- UNIFORM -->
	<script type="text/javascript" src="../../js/uniform/jquery.uniform.min.js"></script>
	<!-- WIZARD -->
	<script src="../../js/bootstrap-wizard/jquery.bootstrap.wizard.min.js"></script>
	<!-- WIZARD -->
	<script src="../../js/jquery-validate/jquery.validate.min.js"></script>
	<script src="../../js/jquery-validate/additional-methods.min.js"></script>
	<script src="../../js/bootstrap-wizard/form-wizard.js"></script>
	<!-- NESTABLE LISTS -->
	<script type="text/javascript" src="../../js/nestable/jquery.nestable.min.js"></script>
	<!-- COOKIE -->
	<script type="text/javascript" src="../../js/jQuery-Cookie/jquery.cookie.min.js"></script>
	<!-- CUSTOM SCRIPT -->
	<script src="../../js/script.js"></script>

	<script src="../../js/Sortable.min.js"></script>

	<script>


		var NewPages = function () {
			var divId = 0;//divId
			var currDivId = "", type = "", imagePath = "", obj = {}, couponAmount = 1, upLoadIndex = 0, rows = 1, inputValue = "";//当前操作的Div
			var page = {}, id = "", flag = "", selectDiv = "";//点击加内容时 操作的Div
			var defaultImg = "http://img1.yiigoo.com/images/200.jpg", size = 750;
			var bannerImg = "http://img1.yiigoo.com/images/350.jpg";
			var libao = "";
			//添加Div
			var addDiv = function () {
				obj = {};
				couponAmount = 1;
				rows = 1;
				$(".UIsidebar").hide();
				var target = $(this).attr("data-target");
				divId++;
				currDivId = "div" + divId;
				$(".app-entry").find(".actions").hide();
				if ($(".app-entry>.app-field").hasClass("tips")) $(".tips").hide();
				$("#" + target).find(".divId").attr("id", "div" + divId);

				type = $("#" + target).find(".divId").attr("data-type");
				//增加Json 属性
				initJson(target);
				if (selectDiv == "")
					$(".app-entry").append($("#" + target).html());
				else {
					$("#" + selectDiv).after($("#" + target).html());
				}
				currDivId = "div" + divId;
				$("#div" + divId).find(".actions").show();

				leftClick();
				selectDiv = "";

			}
			//初始化json
			var initJson = function (target) {
				obj = {}
				obj.type = type;
				switch (type) {
					case "banner":
						obj.amount = 1;
						obj.rows = 1;
						/* obj.imagePath="";
						obj.linkUrl=""; */
						obj.productList = [];
						break;
					case "product":
						obj.amount = 2;
						obj.rows = 1;
						obj.productList = [];
						break;
					case "coupon":
						obj.amount = couponAmount;
						obj.couponList = [];
						break;
					case "category":
						obj.amount = 4;
						obj.rows = 1;
						obj.productList = [];
						break;
					case "swiper":
						obj.amount = 4;
						obj.rows = 1;
						obj.productList = [];
						break;
					case "pairs":
						obj.amount = couponAmount;
						obj.rows = 1;
						obj.productList = [{productIds: ''}];
						break;
				}
				$("#" + target).find(".divId").attr("json", JSON.stringify(obj));
			}

			//左侧点击事件
			var leftClick = function () {
				//删除
				$("#div" + divId).find(".delete").unbind("click").click(function () {
					var that = $(this);

					$.confirm("确认删除吗?", function () {

						divId--;
						$(".UIsidebar").hide();
						$(that).closest(".app-field").remove();
					});

				});
				//添加
				$("#div" + divId).find(".add").unbind("click").click(function () {

					var top = $(this).closest(".divId")[0].offsetTop;
					$("#addContent").find(".app-sidebar-inner").css("top", top);
					html = $("#addContent").html();
					selectDiv = $(this).closest(".divId").attr("id");

					$(".UIsidebar").empty().append(html).show();
					$(".UIsidebar").find(".add_banner,.add_product,.add_coupon,.add_category,.add_swiper,.add_pairs").click(addDiv);
				});
				//编辑
				$("#div" + divId).find(".edit").unbind("click").click(appEntryClick);
				$(".group").click(function () {
					$(".actions").hide();
					$(".UIsidebar").empty();
					$(this).next().show();

				});
			}

			//左侧编辑点击
			var appEntryClick = function () {
				couponAmount = 1;
				rows = 1;
				var that = $(this).closest(".divId");
				//获取类型

				var html = "", json = JSON.parse($(that).attr("json"));//取数据			

				var top = $(that)[0].offsetTop;
				currDivId = $(that).attr("id");
				type = $(that).attr("data-type");
				switch (type) {
					case "banner":
						$("#editBanner").find(".app-sidebar-inner").css("top", top);
						html = $("#editBanner").html();
						$(".UIsidebar").empty().append(html).show();
						//点击单选框
						$(".UIsidebar").find("[name=product_radio]").unbind("click").click(function () {
							couponAmount = $(this).val();
							$("#" + currDivId).attr("couponAmount", couponAmount);
							//生成banner
							createProductDiv();
							setImageSize();
						});
						if (json.amount != null) {
							//选中列数
							couponAmount = json.amount;
							//设置行数							
							$(".UIsidebar").find("[name=rows]").val(json.rows);
							$(".UIsidebar").find("[name=product_radio]:eq(" + (couponAmount - 1) + ")").trigger("click");

							//$(".UIsidebar").find("[name=rows]").trigger("blur");
							var j = JSON.parse($("#" + currDivId).attr("json"));

							$.each(j.productList, function (index, item) {
								$("#" + currDivId).find("li:eq(" + index + ")").find("img").attr("src", item.imagePath);
								$("#" + currDivId).find("li:eq(" + index + ")").attr("inputid", item.productId);
								if (item.imagePath != defaultImg) {
									var t = $(".UIsidebar").find(".lst-addimg:eq(" + index + ")");
									$(t).find("[name=productId]").val(item.productId);

									$(t).find(".newImg").find("img").attr("src", item.imagePath);
									$(t).find(".aImg").hide();
									$(t).find(".newImg").show();
								} else {
									$(t).find(".aImg").show();
									$(t).find(".newImg").hide();
								}

							});
						}

						/* if(json!=null){
							$(".UIsidebar").find("[name=productId]").val(json.linkUrl)	
							if(json.imagePath!=""){
							$(".UIsidebar").find(".lst-addimg").find("img").attr("src",json.imagePath);
							$(".UIsidebar").find(".aImg").hide();
							$(".UIsidebar").find(".newImg").show();
							}
						} */
						break;
					case "product":
						$("#editProduct").find(".app-sidebar-inner").css("top", top);
						html = $("#editProduct").html();
						$(".UIsidebar").empty().append(html).show();
						$(".UIsidebar").find("[name=product_radio]").unbind("click").click(function () {
							couponAmount = $(this).val();
							$("#" + currDivId).attr("couponAmount", couponAmount);
							//生成产品区域
							createProductDiv();
							setImageSize();
						});
						$(".UIsidebar").find("[name=rows]").unbind("blur").blur(function () {
							couponAmount = $(".UIsidebar").find("[name=product_radio]:checked").val();
							$("#" + currDivId).attr("couponAmount", couponAmount);
							//生成产品区域
							createProductDiv();
							setImageSize();
						});


						if (json.amount != null) {
							//选中列数
							couponAmount = json.amount;
							//设置行数							
							$(".UIsidebar").find("[name=rows]").val(json.rows);
							$(".UIsidebar").find("[name=product_radio]:eq(" + (couponAmount - 2) + ")").trigger("click");

							//$(".UIsidebar").find("[name=rows]").trigger("blur");
							var j = JSON.parse($("#" + currDivId).attr("json"));

							$.each(j.productList, function (index, item) {
								$("#" + currDivId).find("li:eq(" + index + ")").find("img").attr("src", item.imagePath);
								$("#" + currDivId).find("li:eq(" + index + ")").attr("inputid", item.productId);
								if (item.imagePath != defaultImg) {
									var t = $(".UIsidebar").find(".lst-addimg:eq(" + index + ")");
									$(t).find("[name=productId]").val(item.productId);

									$(t).find(".newImg").find("img").attr("src", item.imagePath);
									$(t).find(".aImg").hide();
									$(t).find(".newImg").show();
								} else {
									$(t).find(".aImg").show();
									$(t).find(".newImg").hide();
								}

							});
						}

						break;
					case "swiper":
						$("#editSwiper").find(".app-sidebar-inner").css("top", top);
						html = $("#editSwiper").html();
						$(".UIsidebar").empty().append(html).show();
						$(".UIsidebar").find("[name=product_radio]").unbind("click").click(function () {
							couponAmount = $(this).val();
							$("#" + currDivId).attr("couponAmount", couponAmount);
							//生成产品区域
							createProductDiv();
							setImageSize();
						});
						$(".UIsidebar").find("[name=rows]").unbind("blur").blur(function () {
							couponAmount = $(".UIsidebar").find("[name=product_radio]:checked").val();
							$("#" + currDivId).attr("couponAmount", couponAmount);
							//生成产品区域
							createProductDiv();
							setImageSize();
						});


						if (json.amount != null) {
							//选中列数
							couponAmount = json.amount;
							//设置行数							
							$(".UIsidebar").find("[name=rows]").val(json.rows);
							$(".UIsidebar").find("[name=product_radio]:eq(" + (couponAmount - 2) + ")").trigger("click");

							//$(".UIsidebar").find("[name=rows]").trigger("blur");
							var j = JSON.parse($("#" + currDivId).attr("json"));

							$.each(j.productList, function (index, item) {
								$("#" + currDivId).find("li:eq(" + index + ")").find("img").attr("src", item.imagePath);
								$("#" + currDivId).find("li:eq(" + index + ")").attr("inputid", item.productId);
								if (item.imagePath != defaultImg) {
									var t = $(".UIsidebar").find(".lst-addimg:eq(" + index + ")");
									$(t).find("[name=productId]").val(item.productId);

									$(t).find(".newImg").find("img").attr("src", item.imagePath);
									$(t).find(".aImg").hide();
									$(t).find(".newImg").show();
								} else {
									$(t).find(".aImg").show();
									$(t).find(".newImg").hide();
								}

							});
						}

						break;
					case "coupon":
						$("#editCoupon").find(".app-sidebar-inner").css("top", top);
						html = $("#editCoupon").html();
						$(".UIsidebar").empty().append(html).show();

						$(".UIsidebar").find("[name=template_style]").unbind("click").click(function () {
							couponAmount = $(this).val(), li = "", libao = "";
							var c = couponAmount == 5 ? 5 : couponAmount;
							c = couponAmount == 6 ? 6 : couponAmount;
							$("#" + currDivId).attr("couponAmount", c);
							if (couponAmount == 5) { libao = 5; couponAmount = 1; }
							if (couponAmount == 6) { libao = 6; couponAmount = 1; }
							//控制右侧上传图片个数
							for (var i = 1; i <= couponAmount; i++) {
								$(".radio" + i).show();

								li += '<li><a href="javascript:;"><img src="http://img1.yiigoo.com/images/' + (couponAmount == 1 ? "350" : "200") + '.jpg"></a></li>';
							}
							for (var j = 1; j <= 4; j++) {
								$(".radio" + j).hide();
							}
							$(".radio" + couponAmount).show();

							//控制左侧显示列数							
							var cl = "group-col-" + couponAmount;
							$("#" + currDivId).find("ul").empty().append(li).attr("class", "").addClass(cl);
							setTimeout(setImage, 2000);
							setImageSize();
							fileUpLoad();

						});

						if (json.amount != null) {
							couponAmount = json.amount;

							$(".UIsidebar").find("[name=template_style]:eq(" + (couponAmount - 1) + ")").trigger("click");
							if (couponAmount == 5 || couponAmount == 6) couponAmount = 1;
							if (typeof json.couponList != "undefined") {
								//循环设置						

								$.each(json.couponList, function (index, item) {
									$("#" + currDivId).find("li:eq(" + index + ")").find("img").attr("src", item.imagePath);
									$("#" + currDivId).find("li:eq(" + index + ")").attr("inputid", item.batchId);
									if (item.imagePath != "" && item.imagePath != defaultImg && item.imagePath != bannerImg) {
										var t = $(".UIsidebar").find(".radio" + couponAmount).find(".lst-addimg:eq(" + index + ")");
										$(t).find("[name=productId]").val(item.batchId);

										$(t).find(".newImg").find("img").attr("src", item.imagePath);
										$(t).find(".aImg").hide();
										$(t).find(".newImg").show();

									}
								});
							}

						}

						break;
					case "category":
						$("#editCategory").find(".app-sidebar-inner").css("top", top);
						html = $("#editCategory").html();
						$(".UIsidebar").empty().append(html).show();

						$(".UIsidebar").find("[name=rows]").unbind("blur").blur(function () {
							couponAmount = $(".UIsidebar").find("[name=product_radio]:checked").val();
							$("#" + currDivId).attr("couponAmount", couponAmount);
							createCategoryDiv();

						});
						$(".UIsidebar").find("[name=product_radio]").unbind("click").click(function () {
							couponAmount = $(this).val();
							$("#" + currDivId).attr("couponAmount", couponAmount);
							//生成产品区域
							createCategoryDiv();

						});



						if (json.amount != null) {
							//选中列数
							couponAmount = json.amount;
							//设置行数							
							$(".UIsidebar").find("[name=rows]").val(json.rows);

							$(".UIsidebar").find("[name=product_radio]:eq(" + (couponAmount - 4) + ")").trigger("click");
							var j = JSON.parse($("#" + currDivId).attr("json"));

							$.each(j.productList, function (index, item) {
								$("#" + currDivId).find("li:eq(" + index + ")").find("img").attr("src", item.imagePath);
								$("#" + currDivId).find("li:eq(" + index + ")").attr("inputid", item.productId);
								if (item.imagePath != defaultImg) {
									var t = $(".UIsidebar").find(".lst-addimg:eq(" + index + ")");
									$(t).find("[name=productId]").val(item.linkUrl);

									$(t).find(".newImg").find("img").attr("src", item.imagePath);
									$(t).find(".aImg").hide();
									$(t).find(".newImg").show();
								} else {
									$(t).find(".aImg").show();
									$(t).find(".newImg").hide();
								}

							});
						}
						break;
						case "pairs":
							$("#editPairs").find(".app-sidebar-inner").css("top", top);
							html = $("#editPairs").html();
							$(".UIsidebar").empty().append(html).show();
							if (json.amount != null) {
								//选中列数
								couponAmount = json.amount;
								//设置行数							
								$(".UIsidebar").find("[name=rows]").val(json.rows);
								$(".UIsidebar").find("[name=product_radio]:eq(" + (couponAmount - 1) + ")").trigger("click");

								//$(".UIsidebar").find("[name=rows]").trigger("blur");
								var j = JSON.parse($("#" + currDivId).attr("json"));
								var item = j.productList[0]
								if (item.imagePath) {
									var index = 0;
									$("#" + currDivId).find("li:eq(" + index + ")").find("img").attr("src", item.imagePath);
									// $("#" + currDivId).find("li:eq(" + index + ")").attr("inputid", item.productId);
									if (item.imagePath != defaultImg) {
										var t = $(".UIsidebar").find(".lst-addimg:eq(" + index + ")");
										$(t).find(".newImg").find("img").attr("src", item.imagePath);
										$(t).find(".aImg").hide();
										$(t).find(".newImg").show();
									} else {
										$(t).find(".aImg").show();
										$(t).find(".newImg").hide();
									}
								}
								triggerSelectProduct(item.productIds ? item.productIds.split(',') : [])
							}
							break;

				}
				setImageSize();

				//上传图片后事件
				fileUpLoad();
				delImg();
				getValue();


			}
			var triggerSelectProduct = function (productIds) {
				if (productIds.length) {
					$(".pairsInput").val(productIds.join(','))
					// $('.select-product-id').text(' 已选商品:' + productIds.join(','))
					// $('.delect-product').show()
				} else {
					$(".pairsInput").val('')
					// $('.delect-product').hide()
					// $('.select-product-id').text(' 未选择任何商品')
				}
			};
			var setImageSize = function () {

				switch (couponAmount) {
					case "1":
						size = 750;
						break;
					case "2":
						size = 335
						break;
					case "3":
						size = 220;
						break;
					case "4":
						size = 166;
						break;
				}
				//if(type=="banner")size=750;
				if (type == "category") size = 166;
				if (type == "category" && (couponAmount == 5 || couponAmount == 6)) size = 56;
				//图片宽度
				$(".UIsidebar").find(".divimgsize").show();
				$(".UIsidebar").find(".imgsize").html(size);
			}
			var createCategoryDiv = function () {
				var li = "";
				$("#" + currDivId).attr("couponAmount", couponAmount);
				var cl = "group-col-" + couponAmount;
				var lo = "col-lst4";
				$(".UIsidebar").find("[name=formDiv]").find("div:eq(0)").attr("class", "").addClass("controls " + lo);
				$("#" + currDivId).find(".group").empty();
				//循环生成左侧
				rows = $(".UIsidebar").find("[name=rows]").val();
				if (rows == 0 || rows == "") rows = 1;
				for (var i = 1; i <= rows * couponAmount; i++) {
					li += '<li><a href="javascript:;"><img src="' + defaultImg + '"></a></li>';
				}
				var ul = '<ul class=' + cl + '>' + li + '</ul>';
				//添加一行
				$("#" + currDivId).find(".group").empty().append(ul);

				li = "";
				for (var m = 0; m < (rows * couponAmount); m++) {
					li += $("#uploadCategoryHtml").html();
				}
				$(".UIsidebar").find("[name=formDiv]").find(".controls").empty().append(li);

				setTimeout(setImage, 2000);
				delImg();
				fileUpLoad();
				getValue();


			}

			var createProductDiv = function () {
				li = ""; rows = 1;
				$("#" + currDivId).attr("couponAmount", couponAmount);
				var cl = "group-col-" + couponAmount;
				var lo = "col-lst" + couponAmount;
				if (type == "banner" && couponAmount == 1) lo = "col-lst2";
				$(".UIsidebar").find("[name=formDiv]").find("div:eq(0)").attr("class", "").addClass("controls " + lo);
				$("#" + currDivId).find(".group").empty();
				//循环生成左侧
				rows = $(".UIsidebar").find("[name=rows]").val();

				if (rows == 0 || rows == "") rows = 1;
				li = "";

				for (var i = 1; i <= rows * couponAmount; i++) {
					li += '<li><a href="javascript:;"><img src="' + defaultImg + '"></a></li>';
				}
				var ul = '<ul class="' + cl + '">' + li + '</ul>';
				//添加一行
				$("#" + currDivId).find(".group").append(ul);

				//增加上传区域
				li = "";
				for (var m = 0; m < (rows * couponAmount); m++) {
					li += $("#uploadHtml").html();
				}
				$(".UIsidebar").find("[name=formDiv]").find(".controls").empty().append(li);

				setTimeout(setImage, 2000);

				delImg();
				fileUpLoad();
				getValue();


			}


			//上传图片后的处理
			var setImage = function () {
				var $currSelected = $("#" + currDivId).find("li:eq(" + upLoadIndex + ")");
				if (imagePath != "" && type != "header")
					$currSelected.html("<img  src=" + imagePath + ">");
				obj = {};

				switch (type) {
					case "banner":

						v = $currSelected.attr("inputId");
						$("#" + currDivId).find("li:eq(" + upLoadIndex + ")").attr("inputid", v || "");

						obj.type = "banner";
						obj.amount = couponAmount;
						obj.rows = rows;
						obj.productList = [];
						/* obj.imagePath=$("#"+currDivId).find("li").find("img").attr("src");
						if(typeof $currSelected.attr("inputId")=="undefined")
							obj.linkUrl="";
						else
						obj.linkUrl=$currSelected.attr("inputId");
						if(obj.linkUrl!=""&&obj.linkUrl.indexOf("http://")==-1)obj.linkUrl="http://"+obj.linkUrl; */

						for (var i = 0; i < $("#" + currDivId).find("li").length; i++) {
							var p = {};
							p.productId = $("#" + currDivId).find("li:eq(" + i + ")").attr("inputId");
							p.imagePath = $("#" + currDivId).find("li:eq(" + i + ")").find("img").attr("src");
							p.index = i;
							obj.productList.push(p);
						};
						$("#" + currDivId).attr("json", JSON.stringify(obj));

						break;
					case "product":

						obj.type = "product";
						obj.amount = couponAmount;
						obj.rows = rows;
						obj.productList = [];

						for (var i = 0; i < $("#" + currDivId).find("li").length; i++) {
							var p = {};
							p.productId = $("#" + currDivId).find("li:eq(" + i + ")").attr("inputId");
							p.imagePath = $("#" + currDivId).find("li:eq(" + i + ")").find("img").attr("src");
							p.index = i;
							obj.productList.push(p);
						};
						$("#" + currDivId).attr("json", JSON.stringify(obj));



						break;
					case "coupon":

						obj.type = "coupon";
						obj.amount = $("#" + currDivId).attr("couponamount");
						obj.couponList = [];
						for (var i = 0; i < $("#" + currDivId).find("li").length; i++) {
							var coupon = {};
							coupon.batchId = $("#" + currDivId).find("li:eq(" + i + ")").attr("inputId");
							coupon.imagePath = $("#" + currDivId).find("li:eq(" + i + ")").find("img").attr("src");
							//coupon.imagePath=coupon.imagePath.replace(defaultImg,"");

							coupon.index = i;
							obj.couponList.push(coupon);
						};

						$("#" + currDivId).attr("json", JSON.stringify(obj));

						break;
					case "header":
						page.pageTitle = $(".UIsidebar").find("[name=pageTitle]").val();
						$(".UIpreview-headder").html(page.pageTitle);
						page.pageLink = $(".UIsidebar").find("[name=pageLink]").val();
						page.shareTitle = $(".UIsidebar").find("[name=shareTitle]").val();
						page.shareContent = $(".UIsidebar").find("[name=shareContent]").val();
						page.shareLink = $(".UIsidebar").find("[name=shareLink]").val();
						page.shareImage = $(".UIsidebar").find("img").attr("src");
						if (page.shareImage == "undefined")
							page.shareImage = "";
						page.pageType = $(".UIsidebar").find("select option:selected").val();

						break;
					case "category":

						obj.type = "category";
						obj.amount = $("#" + currDivId).attr("couponamount");
						obj.rows = rows;
						obj.productList = [];

						for (var i = 0; i < $("#" + currDivId).find("li").length; i++) {
							var p = {};
							p.linkUrl = $("#" + currDivId).find("li:eq(" + i + ")").attr("inputId") || null;
							if (p.linkUrl == null) p.linkUrl = "";
							if (p.linkUrl.indexOf("http://") == -1) p.linkUrl = "http://" + p.linkUrl;

							p.imagePath = $("#" + currDivId).find("li:eq(" + i + ")").find("img").attr("src");
							p.index = i;
							obj.productList.push(p);
						};
						$("#" + currDivId).attr("json", JSON.stringify(obj));



						break;
					case "pairs": 
						obj.type = "pairs";
						obj.amount = couponAmount;
						obj.rows = rows;
						obj.productList = [{}]
						obj.productList[0].imagePath = $("#" + currDivId).find("img").attr("src");
						var json = JSON.parse($("#" + currDivId).attr("json"));
						var productIds = json.productList[0].productIds
						obj.productList[0].productIds = productIds
						$("#" + currDivId).attr("json", JSON.stringify(obj));
						break;
				}

			}
			//删除图片
			var delImg = function () {

				$(".newImg").unbind("click").click(function () {
					var that = $(this).closest(".lst-addimg");
					$(that).find(".newImg").hide();
					$(that).find(".aImg").show();
					var index = $(that).index();
					$("#" + currDivId).find("li:eq(" + index + ")").empty().append("<img src=" + defaultImg + ">");


				});
				if (!$(".app-entry>.app-field").hasClass("tips")) $(".tips").hide();
			}
			//产品ID或者批次ID离开事件
			var getValue = function () {
				$("[name=productId]").blur(function () {
					var v = $(this).val();

					if (v == "") return false;

					var $target = $(this).closest(".lst-addimg");
					var img = $target.find(".newImg").find("img").attr("src");

					if (typeof img != "undefined")
						upLoadIndex = $target.index();


					$("#" + currDivId).find("li:eq(" + upLoadIndex + ")").attr("inputid", v);
					setImage();

				})
			}
			var showEditDiv = function () {
				$(".divId").unbind("click").click(function () {
					$(".actions").hide();
					$(this).find(".actions").show();
					$(this).find(".edit").trigger("click");
				});
			}


			//上传图片
			var fileUpLoad = function () {
				$('.progress-bar').css('width', '0%');
				$('.progress').hide();
				$("[upload-file=uploadImg]").fileupload({
					url: App.getContextPath() + "admin/file/uploadFile.do",
					formData: {
						fileType: "Promotion"
					},
					dataType: 'json',
					acceptFileTypes: /(\.|\/)(gif|jpe?g|png|JPG?g)$/i,
					iframe: true,
					maxNumberOfFiles: 1,
					autoUpload: true,
					start: function (e) {
						$('.progress').fadeIn(300);
						return true;
					},
					done: function (e, data) {
						var result = data.result;
						if (result.message != "") {
							$.alert(result.message)
							return false;
						} else {
							var $tr = $(this).closest(".lst-addimg");
							upLoadIndex = $tr.index();
							$tr.find(".aImg").hide();
							$tr.find(".newImg").find("img").attr("src", result.fileUrl);
							$tr.find(".newImg").show();
							imagePath = result.fileUrl;

							setImage();
							upLoadIndex = 0;
							imagePath = "";
						}

					},
					progressall: function (e, data) {
						var progress = parseInt(data.loaded / data.total * 100, 10);
						$('.progress-bar').css('width', progress + '%');
					}
				}).on('fileuploaddone', function (e, data) {
					$(".progress").fadeOut(300);

				});
			};

			//保存
			var savePage = function () {
				//循环左侧获取结构及数据
				var content = "";
				if ($(".app-entry").find(".divId").length == 0) {
					$.alert("请维护页面模板");
					return false;
				}
				if (page.pageType == "-1" || page.pageTitle == "" || page.shareTitle == "" || page.shareContent == "" || page.shareImage == "" || page.shareLink == "" || page.shareImage == null) {
					$.alert("请点击页面标题维护页面基本信息");
					return false;
				}
				$.each($(".app-entry").find(".divId"), function () {
					content += $(this).attr("json") + ",";
				});

				content = content.substr(0, content.length - 1);
				page.pageContent = "[" + content + "]";



				if (page.shareLink != "" && page.shareLink.indexOf("http://") == -1) page.shareLink = "http://" + page.shareLink;
				if (flag != "edit") {
					page.id = null; page.publishStatus = "NoPublish";
					//page.pageType=$(".UIsidebar").find("select option:selected").val();
				}

				$.blockUI();
				$.ajax({
					type: "post",
					url: App.getContextPath() + "admin/pages/savePages.do",
					data: $.param({ page: JSON.stringify(page) }),
					async: true,
					success: function (result) {
						id = result.extra;
						page.id = id;
						flag = "edit";
						if (isreview) {
							review();
						} else {
							$.alert("保存成功");
							$.unblockUI();
						}
						isreview = false;

					}

				});

			}
			//获取模板 并初始化页面
			var getPageById = function () {
				page.id = id;
				$.ajax({
					type: "post",
					url: App.getContextPath() + "admin/pages/getPagesById.do",
					data: { id: id },
					async: true,
					success: function (result) {
						$(".tips").hide();
						page = eval(result);
						if (flag == 'copy') {
							page.pageLink = link;
							page.pageType = "-1";
						}
						var content = eval('(' + result.pageContent + ')');
						$(".UIpreview-headder").html(page.pageTitle);
						var str = "";
						$.each(content, function (index, item) {
							divId++;
							type = item.type
							obj = item;
							currDivId = "div" + divId;
							var c = "group-col-" + obj.amount;
							if (type == "coupon" && obj.amount == 5)
								c = "group-col-1";
							str = '<div class="app-field divId" data-type="' + type + '" id="' + currDivId + '" >';
							str += '<div class="group">';
							str += '<ul class="' + c + '">';

							if (type == "banner") {
								$.each(obj.productList, function (i, m) {
									str += '<li inputId="' + m.productId + '"><a href="javascript:;"><img src="' + m.imagePath + '"></a></li>';

								});
							}
							if (type == "product") {
								$.each(obj.productList, function (i, m) {
									str += '<li inputId="' + m.productId + '"><a href="javascript:;"><img src="' + m.imagePath + '"></a></li>';

								});
							}
							if (type == "coupon") {

								$.each(obj.couponList, function (i, m) {

									str += '<li inputId="' + m.batchId + '"><a href="javascript:;"><img src="' + (m.imagePath == "" ? defaultImg : m.imagePath) + '"></a></li>';
								});
							}
							if (type == "category") {
								$.each(obj.productList, function (i, m) {
									str += '<li inputId="' + m.linkUrl + '"><a href="javascript:;"><img src="' + m.imagePath + '"></a></li>';

								});
							}
							if (type == "pairs") {
								var product = obj.productList[0];
								var imagePath = product.imagePath ? product.imagePath : '../../img/nessn269.jpg'
								str += '<li><a href="javascript:;"><img src="' + imagePath + '"></a></li>';
							}

							str += '</ul>';
							str += '</div>';
							str += '<div class="actions" style="display: none;">';
							str += '<div class="actions-wrap">';
							str += '<span class="action edit">编辑</span>';
							str += '<span class="action add">加内容</span>';
							str += '<span class="action delete">删除</span>';
							str += '</div>';
							str += '</div>';
							str += '</div>';

							$(".app-entry").append(str);
							leftClick();
							$("#" + currDivId).attr("json", JSON.stringify(item));
						});
					}

				});
			}
			//预览
			var review = function () {
				$.blockUI();
				$.ajax({
					type: "get",
					url: App.getContextPath() + "admin/pages/review.do",
					async: true,
					data: { id: id },
					success: function (result) {
						$("#box-qrcode").find("img").attr("src", "");
						$.unblockUI();
						if (result.type == "success") {
							$("#box-qrcode").find(".modal-title").html("预览");
							$("#box-qrcode").find("a").attr("href", page.pageLink.replace("static/", "static/review/"));
							$("#box-qrcode").find("img").attr("src", result.extra);
							$("#box-qrcode").modal("show");
						} else {
							$.alert(result.content);
						}

					}
				});
			}
			var isreview = false; var link = "";
			var $mainDataTable = null;
			var searchProduct = function () {
				var url = App.getContextPath() + "admin/product/searchProductList.do?q=" + $("input[name=q]").val();
				if ($mainDataTable) {
					$mainDataTable.api().ajax.url(url).load();
					return;
				}
				var dtSetting = $.dataTableSetting({
					"ajaxSource": url,
					"serverSide": true,
					"bFilter": false,// 去掉搜索框
					"bLengthChange": true,// 每页显示数量
					"sScrollX": "100%",
					"sScrollXInner": "100%",
					"iDisplayLength": 10,

					"bSort": false,
					"aoColumns": [{
						"mDataProp": "id",
						"sTitle": "ID",
						"width": "5%"
					}, {
						"mDataProp": "packTitle",
						"sTitle": "产品名称",
						"width": "65%",
						"render": function (data, type, row) {
							return "<div style='display: inline-flex'><div><img width=50 height=50 src=" + getProductImage(row.imageUrl, "-200*200.jpg") + "></div><div><a href='" + App.getDomain() + "/product/product.html?productId=" + row.id + "' target='_blank'>" + row.productName + "</a><br><span class='text-danger'>￥" + row.productSalePrice + " </span></div></div>";
						}
					}
						, {
							"sTitle": "颜色",
							"mDataProp": "shortName",
							"width": "15%"

						}
						, {
							"sTitle": "销售价",
							"mDataProp": "imageUrl",
							"class": "hide",
							"width": "0%"

						}
						, {
							"sTitle": "操作",
							"width": "15%",
							"render": function (data, type, row) {
								var str = ''
								var id = row.id + ''
								var json = JSON.parse($("#" + currDivId).attr("json"));
								var isHas = false
								var product = json.productList[0];
								var productIds = product.productIds || ''
								productIds = productIds ? productIds.split(',') : []
								var index = productIds.indexOf(id)
								isHas = index > -1
								if (!isHas) {
									str += "<a class='btn btn-success btn-add-product' href='javascript:;' productId='" + id + "'><i class='fa fa-pencil-square-o'></i> 选择</a>";
								} else {
									str += "<a class='btn btn-danger btn-add-product' href='javascript:;' productId='" + id + "'><i class='fa fa-trash-o'></i> 取消</a>";
								}
								return str
							}

						}]
				});
				$mainDataTable = $("#productpack_product").dataTable(dtSetting);
			}
			return {
				init: function () {
					$(".UIsidebar").hide();

					$(".UIpreview").find(".add_banner,.add_product,.add_coupon,.add_category,.add_swiper,.add_pairs").click(addDiv);
					$(".bt-submit").unbind("click").click(savePage);
					$(".bt-review").click(function () { isreview = true; savePage() });
					id = $.getUrlParam("id");
					flag = $.getUrlParam("flag");


					if (id != null) getPageById();
					else {
						page.pageTitle = "";
						page.pageType = "-1";
						page.shareTitle = ""
						page.shareContent = ""
						page.shareImage = ""
						page.shareLink = "";
						page.pageLink = link;
						page.shareLink = page.pageLink;
					}


					//头部标题点击
					$(".UIpreview-headder").click(function () {

						if (id == null || (flag == "copy" && id != null))
							var p = Date.parse(new Date()) / 1000 + ".html";

						type = "header";
						$("#basicHtml").find(".app-sidebar-inner").css("top", 50);
						$(".UIsidebar").empty().append($("#basicHtml").html()).show();
						$(".UIsidebar").find("select").select2();

						// $(".UIsidebar").find("select").prop("disabled", false);
						$(".UIsidebar").find("select").change(function () {
							var sel = $(this).val();

							if (sel == "-1" || flag == "edit") return false;

							link = $(this).find("option:selected").attr("pageurl");
							if (sel == "Promotion" || sel == "PromotionNoMenu" || sel == "TryProduct" || sel == "Advertising") link = link + p;
							page.pageLink = (window.location.host != "houtai.yiigoo.com" ? "http://mtest.yiigoo.com/" : "http://m.yiigoo.com/") + link;
							$(".UIsidebar").find("[name=pageLink]").val(page.pageLink);
							$(".UIsidebar").find("[name=shareLink]").val(page.pageLink);
							page.pageType = sel;

						});
						fileUpLoad();

						$(".UIsidebar").find("[name=pageTitle]").val(page.pageTitle);
						$(".UIsidebar").find("[name=shareTitle]").val(page.shareTitle);
						$(".UIsidebar").find("[name=shareContent]").val(page.shareContent);
						$(".UIsidebar").find("[name=shareLink]").val(page.shareLink);
						if (id != null && flag == 'edit') {
							$(".UIsidebar").find("select").attr("disabled", "disabled").select2();
							$(".UIsidebar").find("select").select2("val", page.pageType);
						}
						if (typeof page.shareImage != "undefined" && page.shareImage != "") {
							$(".UIsidebar").find("img").attr("src", page.shareImage);
							$(".UIsidebar").find(".aImg").hide();
							$(".UIsidebar").find(".newImg").show();
						}
						delImg();
						$(".UIsidebar").find("[name=pageLink]").val(page.pageLink);
						$(".UIsidebar").find("input").blur(setImage);

					})
					// 点击选择商品
					$('body').on('click','.select-product',function() {
						$("#productpack_detail").modal("show");
						var json = JSON.parse($("#" + currDivId).attr("json"));
						var product = json.productList[0];
						var productIds = product.productIds || ''
						productIds = productIds ? productIds.split(',') : []
						$(".btn-add-product").each(function(index, ele){
							var productId = $(ele).attr('productid')
							var isHas = false
							var index = productIds.indexOf(productId)
							isHas = index > -1
							if (isHas) {
								$(ele).removeClass('btn-success').addClass('btn-danger').html('<i class="fa fa-trash-o"></i> 取消')
							} else {
								$(ele).removeClass('btn-danger').addClass('btn-success').html('<i class="fa fa-pencil-square-o"></i> 选择')
							}
						})
					})
					// 查询商品
					$('body').on('click','.search-product', function() {
						searchProduct();
					})
					// 添加商品
					$('body').on('click', '.btn-add-product', function () {
						var $this = $(this);
						var productId = $this.attr('productid')
						var json = JSON.parse($("#" + currDivId).attr("json"));
						var isHas = false
						var product = json.productList[0];
						var productIds = product.productIds || ''
						productIds = productIds ? productIds.split(',') : []
						var index = productIds.indexOf(productId)
						isHas = index > -1
						if (!isHas) {
							productIds.push(productId)
							$this.removeClass('btn-success').addClass('btn-danger').html('<i class="fa fa-trash-o"></i> 取消')
						} else {
							productIds.splice(index, 1)
							$this.removeClass('btn-danger').addClass('btn-success').html('<i class="fa fa-pencil-square-o"></i> 选择')
						}
						json.productList[0].productIds = productIds.join(',')
						triggerSelectProduct(productIds)
						$("#" + currDivId).attr("json", JSON.stringify(json))
					})
					$("body").on('click', '.delect-product', function(){
						var json = JSON.parse($("#" + currDivId).attr("json"));
						json.productList[0].productIds = ''
						triggerSelectProduct([])
						$('.btn-add-product').removeClass('btn-danger').addClass('btn-success').html('<i class="fa fa-pencil-square-o"></i> 选择')
						$("#" + currDivId).attr("json", JSON.stringify(json))
					})
					$("body").on('keyup','.pairsInput',function(){
						var json = JSON.parse($("#" + currDivId).attr("json"));
						json.productList[0].productIds = $(this).val()
						$("#" + currDivId).attr("json", JSON.stringify(json))
					})
				}

			}
		}();

		$(function () {
			$("#header").load("../head.html");
			App.init(); //Initialise plugins and elements	 
			NewPages.init();
		});

	</script>
</body>

</html>